/*
 * Powered By fanrenqij.com
 * Since 2017 - 2017
 */

package com.fanrenqiji.modules.business.wechatuser.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.entity.WeChatUserEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
/**
 * 持久化接口
 */
public interface WeChatUserDao extends WeChatUserDaoCustom, CrudRepository<WeChatUserEntity, Long> {

    @Query("from WeChatUserEntity where delFlag='" + WeChatUserEntity.DEL_FLAG_NORMAL + "' order by id desc")
    public List<WeChatUserEntity> findAllList();


    @Query("from WeChatUserEntity where delFlag='" + WeChatUserEntity.DEL_FLAG_NORMAL + "' and status =?1 order by id")
    public List<WeChatUserEntity> findWeChatUserEntityByStatus(int status);

    @Modifying
    @Query("update WeChatUserEntity set delFlag='" + WeChatUserEntity.DEL_FLAG_DELETE + "' where id = ?1 ")
    void deleteById(Long id);

}


interface WeChatUserDaoCustom extends BaseDao<WeChatUserEntity> {
}

@Repository
class WeChatUserDaoImpl extends BaseDaoImpl<WeChatUserEntity> implements WeChatUserDaoCustom {

}
